package com.logistics.dao;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import com.logistics.ExpressProperty;
import com.logistics.ExpressPropertyQueryParam;

import cn.easybuild.core.hibernate.StringPojoHibernateHandler;

@Repository
public class ExpressPropertyDaoImpl extends StringPojoHibernateHandler<ExpressProperty> implements ExpressPropertyDao {

	@Override
	public List<ExpressProperty> query(final ExpressPropertyQueryParam param) {
		return queryWithParameter(param, "e", "e.id", new QueryCriteriaSetter() {

			@Override
			public void setCriteria(StringBuffer hql, Map<String, Object> values) {
				if (StringUtils.isNotBlank(param.getCompanyId())) {
					hql.append(" and e.company.entityId = :companyId");
					values.put("companyId", param.getCompanyId());
				}
			}
		});
	}

	@Override
	protected Class<ExpressProperty> getEntityClass() {
		return ExpressProperty.class;
	}

}
